import { createRouter, createWebHistory } from 'vue-router';

const BaseLayout = () => import('~/layout/Base/Index.vue');
const DetailLayout = () => import('~/layout/Detail.vue');

const routes = [
    {
        path: '/',
        redirect: '/detail/test',
        component: BaseLayout,
        children: [
            { path: 'home', name: 'Home', component: () => import('~/views/Home.vue') },
            {
                path: 'detail',
                redirect: '/list',
                component: DetailLayout,
                children: [
                    { path: 'test', name: 'Test', component: () => import('~/views/details/Test.vue') },
                ],
            },
            { path: 'list', name: 'List', component: () => import('~/views/List.vue') },
        ],
    },
    {
        path: '/:pathMatch(.*)*',
        name: '404',
        component: () => import('~/views/404.vue'),
    },
];

export default createRouter({
    // HTML5模式, url上没有#，并且有助于SEO
    history: createWebHistory(),
    routes,
});
